package com.iplant.ams.service.po.dms.maintenance;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.ams.service.basicenum.dms.DMSMaintenanceLevel;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.general.CalendarTool;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 对部件的保养项目(方法)
 *
 * @author YouWang·Peng
 * 2022-8-8 09:20:21
 */
@DBBasePO(TableName = "dms_maintenance_item", Schemas = DBSchemas.AMS, CheckName = {"Code", "DeviceID," +
        "ConfigurationID,Name"}, CodePrefix = "DMI-", CodeAuto = true)
public class DMSMaintenanceItem extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 设备ID
     **/
    @DBCondition
    @DBField
    public int DeviceID = 0;
    @DBJoin(name = "AssetInfoID", tableName = "dms_device_ledger", tableAsName = "dms_device_ledger1", Schemas =
            DBSchemas.AMS,
            MainTableField = "DeviceID")
    public int AssetInfoID = 0;

    /**
     * 设备名称
     **/
    @DBJoin(name = "Name", tableName = "ams_asset_list", tableAsName = "ams_asset_list1", Schemas = DBSchemas.AMS,
            JoinIndex = 2,
            ConditionalJoin = "dms_device_ledger1.AssetInfoID=ams_asset_list1.ID")
    public String DeviceName = "";
    /**
     * 设备编码
     **/
    @DBJoin(name = "Code", tableName = "ams_asset_list", tableAsName = "ams_asset_list1", Schemas = DBSchemas.AMS,
            JoinIndex = 2,
            ConditionalJoin = "dms_device_ledger1.AssetInfoID=ams_asset_list1.ID")
    public String DeviceCode = "";
    /**
     * 构型ID
     **/
    @DBCondition
    @DBField
    public int ConfigurationID = 0;
    /**
     * 构型名称
     **/
    @DBJoin(name = "Name", tableName = "dms_configuration", tableAsName = "dms_configuration1", Schemas = DBSchemas.AMS,
            MainTableField = "ConfigurationID")
    public String ConfigurationName = "";
    @DBJoin(name = "Code", tableName = "dms_configuration", tableAsName = "dms_configuration1", Schemas = DBSchemas.AMS,
            MainTableField = "ConfigurationID")
    public String ConfigurationCode = "";

    /**
     * 最后一次保养时间
     **/
    @DBField
    public Calendar LastMaintenanceTime = CalendarTool.getBasicDate();
    /**
     * 保养资质列表
     **/
    @DBField
    public List<String> QualificationsList = new ArrayList<>();
    /**
     * 保养工具列表
     **/
    @DBField
    public List<String> ToolList = new ArrayList<>();
    /**
     * 保养工时(min)
     **/
    @DBField
    public double WorkTime = 0.0;
    /**
     * 作业指导书
     **/
    @DBField
    public List<String> SOPList = new ArrayList<>();
    /**
     * 保养步骤(必查)
     **/
    public List<DMSMaintenanceStep> StepList = new ArrayList<>();

    /**
     * 保养规则(只读)
     **/
    public List<DMSMaintenanceRule> MaintenanceRuleList = new ArrayList<>();

    /**
     * 项点类型
     */
    @DBCondition
    @DBField
    public int Type = 0;

    @JsonProperty("Type")
    public int getType() {
        return Type;
    }

    /**
     * 顺序
     */
    @DBField
    public int OrderNum = 0;

    /**
     * 保养等级枚举
     */
    @DBCondition
    @DBField
    public int MaintenanceLevel = 0;

    /**
     * 保养等级文本
     */
    public String MaintenanceLevelText = "";

    public DMSMaintenanceItem() {
    }

    public void setType(int type) {
        Type = type;
    }

    @JsonProperty("DeviceID")
    public int getDeviceID() {
        return DeviceID;
    }

    public void setDeviceID(int deviceID) {
        DeviceID = deviceID;
    }

    @JsonProperty("DeviceName")
    public String getDeviceName() {
        return DeviceName;
    }

    public void setDeviceName(String deviceName) {
        DeviceName = deviceName;
    }

    @JsonProperty("DeviceCode")
    public String getDeviceCode() {
        return DeviceCode;
    }

    public void setDeviceCode(String deviceCode) {
        DeviceCode = deviceCode;
    }

    @JsonProperty("ConfigurationID")
    public int getConfigurationID() {
        return ConfigurationID;
    }

    public void setConfigurationID(int configurationID) {
        ConfigurationID = configurationID;
    }

    @JsonProperty("ConfigurationName")
    public String getConfigurationName() {
        return ConfigurationName;
    }

    public void setConfigurationName(String configurationName) {
        ConfigurationName = configurationName;
    }

    @JsonProperty("ConfigurationCode")
    public String getConfigurationCode() {
        return ConfigurationCode;
    }

    public void setConfigurationCode(String configurationCode) {
        ConfigurationCode = configurationCode;
    }

    @JsonProperty("LastMaintenanceTime")
    public Calendar getLastMaintenanceTime() {
        return LastMaintenanceTime;
    }

    public void setLastMaintenanceTime(Calendar lastMaintenanceTime) {
        LastMaintenanceTime = lastMaintenanceTime;
    }

    @JsonProperty("QualificationsList")
    public List<String> getQualificationsList() {
        return QualificationsList;
    }

    public void setQualificationsList(List<String> qualificationsList) {
        QualificationsList = qualificationsList;
    }

    @JsonProperty("ToolList")
    public List<String> getToolList() {
        return ToolList;
    }

    public void setToolList(List<String> toolList) {
        ToolList = toolList;
    }

    @JsonProperty("WorkTime")
    public double getWorkTime() {
        return WorkTime;
    }

    public void setWorkTime(double workTime) {
        WorkTime = workTime;
    }

    @JsonProperty("SOPList")
    public List<String> getSOPList() {
        return SOPList;
    }

    public void setSOPList(List<String> SOPList) {
        this.SOPList = SOPList;
    }

    @JsonProperty("StepList")
    public List<DMSMaintenanceStep> getStepList() {
        return StepList;
    }

    public void setStepList(List<DMSMaintenanceStep> stepList) {
        StepList = stepList;
    }

    @JsonProperty("MaintenanceRuleList")
    public List<DMSMaintenanceRule> getMaintenanceRuleList() {
        return MaintenanceRuleList;
    }

    public void setMaintenanceRuleList(List<DMSMaintenanceRule> maintenanceRuleList) {
        MaintenanceRuleList = maintenanceRuleList;
    }

    @JsonProperty("AssetInfoID")
    public int getAssetInfoID() {
        return AssetInfoID;
    }

    public void setAssetInfoID(int assetInfoID) {
        AssetInfoID = assetInfoID;
    }

    @JsonProperty("OrderNum")
    public int getOrderNum() {
        return OrderNum;
    }

    public void setOrderNum(int orderNum) {
        OrderNum = orderNum;
    }

    @JsonProperty("MaintenanceLevel")
    public int getMaintenanceLevel() {
        return MaintenanceLevel;
    }

    public void setMaintenanceLevel(int maintenanceLevel) {
        MaintenanceLevel = maintenanceLevel;
    }

    @JsonProperty("MaintenanceLevelText")
    public String getMaintenanceLevelText() {
        MaintenanceLevelText = DMSMaintenanceLevel.getEnumType(MaintenanceLevel).getLabel();
        return MaintenanceLevelText;
    }

    public void setMaintenanceLevelText(String maintenanceLevelText) {
        MaintenanceLevelText = maintenanceLevelText;
    }
}
